<template>
  <div class="music-player">
    <div id="music-player-ratio-track">
      <div id="music-player-ratio-played"></div>
    </div>
    <div class="music-player-inner">
      <div class="music-player-inner-left">
        <div id="music-small-img">
          <img src="">
        </div>
      </div>
      <div class="music-player-inner-center">
        <div id="music-isloop" class="round-button">
          <div class="button-img-wrapper">
            <img id="single-loop" src="@/assets/single-loop.svg">
          </div>
        </div>
        <div id="music-on-off" class="round-button waiting" v-on:click="musicOnOff">
          <div class="button-img-wrapper">
            <img id="to-play" src="@/assets/play.svg">
            <img id="to-wait" src="@/assets/pause.svg">
          </div>
        </div>
        <div id="music-volume" class="round-button">
          <div class="button-img-wrapper">
            <img id="single-loop" src="@/assets/volume.svg">
          </div>
        </div>
      </div>
      <div class="music-player-inner-right">
        <div id="music-player-time">
          <span id="music-player-time-now">00:00</span> /
          <span id="music-player-time-all">00:00</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {MokeyPlayer} from "@/player/main.js"

export default {
  name: 'MusicPlayer',
  data: function() {
    return {
    };
  },
  methods: {
    musicOnOff: function() {
      MokeyPlayer.musicOnOff();
    }
  },
  mounted: function() {
    console.log(MokeyPlayer.musicStatusSync);
    MokeyPlayer.init();
  }
}
</script>

<style scoped>
.music-player {
  position: relative;
  width: 100%;
  height: 100%;
}

.music-player-inner {
  display: flex;
  width: 100%;
  height: 100%;
}

.music-player-inner-left {
  box-sizing: border-box;
  width: 360px;
  height: 100%;
  display: flex;
  align-items: center;
  padding-left: 30px;
}

.music-player-inner-center {
  display: flex;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
}

.music-player-inner-right {
  width: 360px;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 30px;
}

#music-player-time {
  font-size: 15px;
  color: gray;
}

#music-small-img {
  background-color: white;
  width: 50px;
  height: 50px;
  border-radius: 5px;
  overflow: hidden;
}

#music-small-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#music-on-off {
  background-color: aliceblue;
  margin: 0 20px;
}

.button-img-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

.button-img-wrapper img {
  position: absolute;
  width: 100%;
  height: 100%;
}

#music-on-off.waiting img#to-wait {
  opacity: 0;
}

#music-on-off.waiting img#to-play {
  opacity: 1;
}

#music-on-off.playing img#to-play {
  opacity: 0;
}

#music-on-off.playing img#to-wait {
  opacity: 1;
}

.round-button {
  box-sizing: border-box;
  position: relative;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 8px 8px;
  cursor: pointer;
}

#music-player-ratio-track {
  background-color: rgb(200, 200, 200);
  width: 100%;
  height: 3px;
  position: absolute;
  top: -3px;
}

#music-player-ratio-played {
  width: 27%;
  height: 100%;
  background-color: rgb(0, 200, 0);
}
</style>
